<template>
  <el-row>
    <el-col>
      <el-col style="margin-top: 20px;margin-left: 5px;margin-bottom: 5px;color:#646464">昨日概况</el-col>
      <el-table :data="mapYList" border style="width: 100%; font-size: 12px;" row-class-name="tabRow">
        <el-table-column align="center" prop="share_pv" label="转发次数"></el-table-column>
        <el-table-column align="center" prop="share_uv" label="转发人数"></el-table-column>
        <el-table-column align="center" prop="session_cnt" label="打开次数"></el-table-column>
        <el-table-column align="center" prop="visit_pv" label="访问次数"></el-table-column>
        <el-table-column align="center" prop="visit_uv" label="访问人数"></el-table-column>
        <el-table-column align="center" prop="visit_uv_new" label="新用户数"></el-table-column>
      </el-table>
      <el-col style="margin-top: 20px;margin-left: 5px;color:#646464">常用功能</el-col>
      <el-col style="margin-top: 20px;">
        <span style="width:24%;display:inline-block;text-align:center"><img src="../images/icon6.png" style="vertical-align: middle;width:26px;margin-right:10px"><span class="hvfont" @click="couponClick">小程序设置</span></span>
        <span style="width:24%;display:inline-block;text-align:center"><img src="../images/icon1.png" style="vertical-align: middle;width:26px;margin-right:10px"><span class="hvfont" @click="retailGoodsClick">发布商品</span></span>
        <span style="width:24%;display:inline-block;text-align:center"><img src="../images/icon7.png" style="vertical-align: middle;width:26px;margin-right:10px"><span class="hvfont" @click="shopSetting">故障上报</span></span>
        <span style="width:24%;display:inline-block;text-align:center"><img src="../images/icon5.png" style="vertical-align: middle;width:26px;margin-right:10px"><span class="hvfont" @click="applyService">意见反馈</span></span>
      </el-col>
    </el-col>
  </el-row>
</template>

<script type="text/ecmascript-6">
  import {resetBreads, sessionOut} from '../../smartlight/common/js/util.js'
  export default{
    data () {
      return {
        qrcodeUrl: '',
        mapYList: [],
        mapY: {
          session_cnt: 0,
          visit_pv: 0,
          visit_uv: 0,
          visit_uv_new: 0,
          share_pv: 0,
          share_uv: 0
        },
        loginType: ''
      }
    },
    methods: {
      retailGoodsClick () {
        this.$router.push({path: '/retailGoods'})
      },
      couponClick () {
        this.$router.push({path: '/retailShopConfig'})
      },
      shopSetting () {
        this.$router.push({path: '/exceptionReportList'})
      },
      applyService () {
        this.$router.push({path: '/feedbackList'})
      }
    },
    mounted () {
      let user = sessionStorage.getItem('user')
      if (user) {
        resetBreads(this)
        user = JSON.parse(user)
        this.loginType = user.type
        var para = {
          type: this.loginType
        }
        this.$http.post('/smartLight/web/member/getVisitCount.htm', para).then(response => {
          var resBody = response.body
          if (resBody.isSuccess === 0) {
            this.mapY = resBody.mapY
            if (this.mapY.share_pv !== undefined && this.mapY.session_cnt !== undefined) {
              if (this.mapY !== '' && this.mapY !== undefined) {
                this.mapYList.push(this.mapY)
              }
            } else {
              this.mapYList = []
            }
          } else if (resBody.isSuccess === 2) {
            sessionOut(this) // session超时处理
          } else {
            this.$message({
              showClose: true,
              message: resBody.errorMsg,
              type: 'error'
            })
          }
        })
      }
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
.hvfont{color:#646464}
.hvfont:hover{color:#20A0FF;cursor:pointer}
</style>
